$(document).ready(function() {
    $(function () {
        $("#retrieve").click(function () {
            let userId = $("#register-userid").val();
            let userName = $("#register-username").val();
            let userQuestion = $("#register-question").val();
            console.log(userId);
            console.log(userName);
            console.log(userQuestion);

            $.ajax({
                url: '/user/forgetPwd',
                type: 'get',
                dataType: 'json',
                async: false,
                data: {"userId": userId, "userName": userName.toString(), "userQuestion": userQuestion.toString()},

                success: function (data) {

                    if(data.length!=0){
                        localStorage.setItem('userId_forget', userId);
                        swal({
                                title: "信息验证成功!",
                                text: "请点击继续！",
                                type: "success",
                                confirmButtonColor: "#2a67ec",
                                confirmButtonText: "继续！"
                            },
                            function (isConfirm) {
                                if (isConfirm) {
                                    window.location.href = "../web/forgetPwd2.html";
                                }
                            });
                    }else {
                        swal({title: "信息验证失败，请查证后再输入！", type: "error"});
                    }
                }

            });

        })
        // $(function (){
        // $("#newPwd").click(function () {
        //     let userId = localStorage.getItem("userId_forget");
        //     let userPwd1 = $("#register-userid").val();
        //     let userPwd2 = $("#register-username").val();
        //     if(userPwd1===userPwd2){
        //         $.ajax({
        //             url: '/user/upDateUserPwd',
        //             type: 'post',
        //             dataType: 'json',
        //             async: false,
        //             data: {"userId": userId, "userPwd": userPwd2},
        //             success: function () {
        //                 swal({title: "密码修改成功，请登录！",
        //                     type: "success",
        //                     confirmButtonColor: "#2a67ec",
        //                      confirmButtonText: "继续！"},
        //                     function (isConfirm) {
        //                         if (isConfirm) {
        //                             window.location.href = "../web/login.html";
        //                         }
        //                     });
        //             }
        //
        //         });
        //     }else {
        //         swal({title:"两次密码输入不一致！请重新输入！",type:"error"})
        //     }
        // })
        // })

    });
})